package com.cskaoyan.controller;

import com.cskaoyan.bean.VO.WxUserIndexVO;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.service.WxUserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wenkaikai
 * @since 2022/08/18 09:19
 */

@RestController
@RequestMapping("wx/user")
public class WxUserController {

    @Autowired
    WxUserService wxUserService;

    @RequestMapping("index")
    public BaseRespVo index() {
        Session session = SecurityUtils.getSubject().getSession();
        Integer userId = (Integer) session.getAttribute("userId");
        if(userId == null){
            return BaseRespVo.ok(0,null,"请重新登入！");
        }
        WxUserIndexVO wxUserIndexVO = wxUserService.queryMsgById(userId);
        return BaseRespVo.ok(0, wxUserIndexVO, "成功");
    }
}